*     complementary error function erfc(x)= 1-erf(x)
*     using formula 7.1.26 on page 299 of Abramowitz & Stegun
      DOUBLE PRECISION FUNCTION RFERFC(RX)
      IMPLICIT NONE
      DOUBLE PRECISION RX

      DOUBLE PRECISION RP, RA1, RA2, RA3, RA4, RA5
      PARAMETER (RP= .3275911  , RA1=  .254829592, RA2=-.284496736,
     &          RA3=1.421413741, RA4=-1.453152027, RA5=1.061405429)
*     with the accuracy of the machine the function returns zero for
*     values for RX of more than 10. ( RFERFC(9.)=4.28E-37 )
      DOUBLE PRECISION RXABS, RT

      RXABS=ABS(RX)

      RT=1./(1.+RP*RXABS)
      RFERFC=RT*(RA1+RT*(RA2+RT*(RA3+RT*(RA4+RT*RA5))))*EXP(-RX*RX)
      IF (RX.LT.0.) RFERFC=2.-RFERFC

      RETURN
      END
